package com.yegs.jindie.service;

import com.yegs.jindie.entity.BasisTO;
import com.yegs.jindie.entity.ToFactory;
import com.yegs.jindie.serviceImpl.LogServiceImpl;
import com.yegs.jindie.util.HttpPloxy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * service通用父类
 */
@Service
public abstract class BaseService {

    @Autowired
    private LogServiceImpl logService;

    @Autowired
    protected BasisTO basisTO;

    @Autowired
    protected ToFactory toFactory;

    public String post(String url, String params){
        logService.saveBeginLog(this.getClass().getName(),"开始执行调度任务");
        String message = null;
        try {
            message =  HttpPloxy.post(url, params);
        }catch (Exception e){
            e.printStackTrace();
            message = e.getMessage();
        }
        logService.saveEndLog(this.getClass().getName(),message);
        return message;
    }

    public String get(String url, String params){
        logService.saveBeginLog(this.getClass().getName(),"开始执行调度任务");
        String message = null;
        try {
            message =  HttpPloxy.get(url, params);
        }catch (Exception e){
            e.printStackTrace();
            message = e.getMessage();
        }
        logService.saveEndLog(this.getClass().getName(),message);
        return message;
    }
    public String get(String url){
        logService.saveBeginLog(this.getClass().getName(),"开始执行调度任务");
        String message = null;
        try {
            message =  HttpPloxy.get(url);
        }catch (Exception e){
            e.printStackTrace();
            message = e.getMessage();
        }
        logService.saveEndLog(this.getClass().getName(),message);
        return message;
    }

}
